import { defineStore } from "pinia";
import { Login } from "@/api/interface";

export const useUserStore = defineStore("chat-room-user", {
  state: (): Login.UserState => ({
    token: "",
    userInfo: { name: "Unknown" }
  }),
  getters: {},
  actions: {
    setToken(token: string) {
      this.token = token;
    },
    clearToken() {
      this.token = "";
    },
    setUserInfo(userInfo: UserState["userInfo"]) {
      this.userInfo = userInfo;
    }
  },
  persist: true
});
